var t, a = require("../../../@babel/runtime/helpers/interopRequireDefault"), e = require("../../../@babel/runtime/helpers/extends"), i = require("../../../@babel/runtime/helpers/defineProperty"), s = a(require("../../../@babel/runtime/regenerator")), o = require("../../../@babel/runtime/helpers/asyncToGenerator"), r = a(require("../../../utils/util.js")), n = getApp(), d = 2 * n.globalData.statusBarHeight + 20;

Page({
    data: {
        statusBarHeight: d,
        repeatStatus: !1,
        isset: "",
        invite: "",
        isrequired: "",
        showChangeID: !1,
        changidInfo: {
            uid: null,
            change_uid: null
        },
        editType: "",
        uploadUrl: "upload.uploadPic",
        form: {
            country: "86",
            mobile: "",
            mobileErr: "",
            password: "",
            passwordErr: "",
            confirm_password: "",
            confirm_passwordErr: "",
            captcha: "",
            province_name: "",
            city_name: "",
            area_name: "",
            province: "",
            city: "",
            area: "",
            address: "",
            gender: "",
            custom_value: "",
            realname: ""
        },
        showBack: !1,
        showSex: !1,
        sexItems: [ {
            name: "男"
        }, {
            name: "女"
        } ],
        is_password: "0",
        customDatas: [],
        form_address: !1,
        form_birthday: !1,
        form_sex: !1,
        date_v1: r.default.formatTime(new Date()).substring(0, 10),
        diydata: [],
        diyform: {},
        types: {
            88: "diyusername",
            99: "diypassword",
            0: "diyinput",
            1: "diytextarea",
            3: "diycheckbox",
            4: "diyradio",
            2: "diyselect",
            7: "diydate",
            9: "diycity",
            5: "diyimage"
        },
        agreementStatus: !1,
        protocol_content: "",
        protocol_title: "",
        agreement_name: "平台协议",
        PlatformAgreement: "",
        showPlatformAgreement: !1,
        imgcode: "",
        agreementCB: !0,
        show2: !1,
        start1: !1,
        codetext: "获取短信验证码",
        provinceData: [],
        cityData: [],
        districtData: [],
        pickerValue: [ 0, 0, 0 ],
        selectAddressData: [],
        isValidation: !0,
        currentDate: new Date().getTime(),
        yzredirect: "",
        nowtime: "2019-09-01",
        country_code: 0,
        fromApp: 0,
        anchorApplyBol: !1,
        isShowAddress: !1,
        orderLocationObj: {
            positioning_success: 0,
            register_province: "",
            register_city: ""
        },
        formOpen: !1,
        default_invite: "",
        datas: {
            form_id: ""
        },
        visibleSet: !1,
        visibleSure: !1,
        is_code: !1,
        balance: "余额",
        point: "积分"
    },
    onLoad: (t = o(s.default.mark(function t(a) {
        var e, i, o, r, d = this;
        return s.default.wrap(function(t) {
            for (;;) switch (t.prev = t.next) {
              case 0:
                return t.next = 2, this.checkAlbum("scope.userLocation");

              case 2:
                if (e = t.sent, console.log("userLocationFlag", e), e) {
                    t.next = 6;
                    break;
                }
                return t.abrupt("return", this.tips("获取位置失败，请重新进入后授权"));

              case 6:
                n.globalData.qqmapkey ? this.getCurrentOrderLocation() : n._getTemplate().then(function(t) {
                    d.getCurrentOrderLocation();
                }), a.editType && this.setData({
                    editType: a.editType
                }), a.is_code && (this.data.is_code = !0), a.anchorApply && this.setData({
                    anchorApplyBol: !0
                }), a.code && this.setData({
                    "form.invite_code": a.code
                }), a.logintype && (this.data.yzredirect = n.getyzredirect()), a.fromApp && 0 != a.fromApp && this.setData({
                    fromApp: a.fromApp
                }), this._initAddressInfo(), a.num && this.setData({
                    "form.mobile": a.num
                }), this.getAllData(), this._initAddressInfo(), i = new Date().getTime(), o = this.timestampToTime(i), 
                r = wx.getStorageSync("userInfo"), this.setData({
                    nowtime: o,
                    nickName: r.userInfo ? r.userInfo.nickName : ""
                });

              case 21:
              case "end":
                return t.stop();
            }
        }, t, this);
    })), function(a) {
        return t.apply(this, arguments);
    }),
    fillInCode: function() {
        this.setData({
            "form.invite_code": this.data.default_invite
        });
    },
    getPhoneNumber: function(t) {
        var a = t.detail;
        "getPhoneNumber:ok" == a.errMsg && this.getPhoneM(a.code);
    },
    back: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    addressinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.address": a
        });
    },
    getPhoneM: function(t) {
        var a = n.getNetAddresss("member.member.miniMemberMobile"), e = this;
        n._postNetWork({
            url: a,
            data: {
                code: t,
                not_validate_page: "0"
            },
            showToastIn: !1,
            success: function(t) {
                var a = t.data;
                1 == a.result ? e.setData({
                    "form.mobile": a.data.phone_info.purePhoneNumber
                }) : wx.showToast({
                    icon: "none",
                    title: a.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    sexSelectBtn: function(t) {
        var a = t.detail.name;
        "男" == a ? this.setData({
            "form.gender": "1",
            sexName: "男"
        }) : "女" == a && this.setData({
            "form.gender": "0",
            sexName: "女"
        }), this.setData({
            showSex: !1
        });
    },
    sexClose: function() {
        this.setData({
            showSex: !1
        });
    },
    bindDateChange_v1: function(t) {
        this.setData({
            "form.birthday": t.detail.value
        });
    },
    openPicker_v1: function() {
        this.setData({
            birthdayShow: !0
        });
    },
    showSexInfo: function() {
        this.setData({
            showSex: !0
        });
    },
    _closeDateLw_v1: function() {
        this.setData({
            showAdd_v1: !1
        });
    },
    showAddBtn_v1: function() {
        this.setData({
            showAdd_v1: !0
        });
    },
    _initAddressInfo: function() {
        var t = this;
        wx.getStorage({
            key: "provinceData",
            success: function(a) {
                console.log("地址信息准备就绪"), t._getProvinceData();
            },
            fail: function(a) {
                n._getNetWork({
                    url: n.getNetAddresss("member.member-address.address"),
                    success: function(a) {
                        var e = a.data, i = e.data.province, s = e.data.city, o = e.data.district;
                        wx.setStorage({
                            key: "provinceData",
                            data: i
                        }), wx.setStorage({
                            key: "cityData",
                            data: s
                        }), wx.setStorage({
                            key: "districtData",
                            data: o
                        }), t._initAddressInfo();
                    },
                    fail: function(t) {},
                    state: !0
                });
            }
        });
    },
    _initDistrict: function(t, a) {
        if (!n._isTextEmpty(t)) return n._isTextEmpty(t.myform.form) || this.setData({
            isShowAddress: 1 == t.myform.base.address
        }), void this.setData({
            "form.province": t.province,
            "form.province_name": t.province_name,
            "form.city": t.city,
            "form.city_name": t.city_name,
            "form.area": t.area,
            "form.area_name": t.area_name,
            districtName: t.province_name + " " + t.city_name + " " + t.area_name,
            "form.address": t.address
        });
        n._isTextEmpty(a) || (this.setData({
            "form.province": a.itemValue1,
            "form.province_name": a.itemName1,
            "form.city": a.itemValue2,
            "form.city_name": a.itemName2,
            "form.area": a.itemValue3,
            "form.area_name": a.itemName3
        }), this.setData({
            districtName: a.itemName1 + " " + a.itemName2 + " " + a.itemName3
        }));
    },
    _getProvinceData: function() {
        var t = this;
        wx.getStorage({
            key: "provinceData",
            success: function(a) {
                t.setData({
                    provinceData: a.data
                }), t.setData({
                    "selectAddressData[0].name": a.data[t.data.pickerValue[0]].areaname,
                    "selectAddressData[0].id": a.data[t.data.pickerValue[0]].id,
                    "selectAddressData[0].index": t.data.pickerValue[0]
                }), t._getCityData();
            }
        });
    },
    _getCityData: function() {
        var t = this.data.selectAddressData[0], a = this;
        wx.getStorage({
            key: "cityData",
            success: function(e) {
                for (var i = [], s = 0; s < e.data.length; s++) e.data[s].parentid == t.id && i.push(e.data[s]);
                a.setData({
                    cityData: i
                }), a.setData({
                    "selectAddressData[1].name": i[a.data.pickerValue[1]].areaname,
                    "selectAddressData[1].id": i[a.data.pickerValue[1]].id,
                    "selectAddressData[1].index": a.data.pickerValue[1]
                }), a._getDistrictData();
            }
        });
    },
    _getDistrictData: function() {
        var t = this.data.selectAddressData[1], a = this;
        wx.getStorage({
            key: "districtData",
            success: function(e) {
                for (var i = [], s = 0; s < e.data.length; s++) e.data[s].parentid == t.id && i.push(e.data[s]);
                a.setData({
                    districtData: i
                }), a.setData({
                    "selectAddressData[2].name": i[a.data.pickerValue[2]].areaname,
                    "selectAddressData[2].id": i[a.data.pickerValue[2]].id,
                    "selectAddressData[2].index": a.data.pickerValue[2]
                });
            }
        });
    },
    bindChange: function(t) {
        var a = t.detail.value;
        this.data.pickerValue[0] != a[0] && (a[1] = 0, a[2] = 0), this.data.pickerValue[1] != a[1] && (a[2] = 0), 
        this.setData({
            "pickerValue[0]": a[0],
            "pickerValue[1]": a[1],
            "pickerValue[2]": a[2]
        }), this._initAddressInfo();
    },
    resultAdd_v1: function() {
        var t = this.data.selectAddressData, a = {
            itemValue1: t[0].id,
            itemName1: t[0].name,
            itemValue2: t[1].id,
            itemName2: t[1].name,
            itemValue3: t[2].id,
            itemName3: t[2].name
        };
        this._initDistrict("", a), this._closeDateLw_v1();
    },
    _initCustomForm: function(t) {
        n._isTextEmpty(t.form) ? this.setData({
            isForm: !1
        }) : 0 != t.form.length ? (this.setData({
            isForm: !0
        }), this.setData({
            customDatas: t.form
        })) : this.setData({
            isForm: !1
        });
    },
    cItemInp: function(t) {
        var a = t.currentTarget.dataset.citemidx, e = t.detail.value;
        this.setData(i({}, "customDatas[" + a + "].value", e));
    },
    onReady: function() {
        var t = this;
        wx.createSelectorQuery().select(".topback").boundingClientRect(function(a) {
            t.setData({
                tabScrollTop: a.top + 10
            });
        }).exec();
    },
    onPageScroll: function(t) {
        t.scrollTop >= this.data.tabScrollTop ? this.setData({
            showBack: !0
        }) : t.scrollTop < this.data.tabScrollTop && this.setData({
            showBack: !1
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {},
    onShareAppMessage: function() {},
    getimgdata: function(t) {
        var a = this, e = n.getNetAddresss("home-page.getCaptcha");
        t && t.captcha ? t.captcha && a.setData({
            imgcode: t.captcha.img
        }) : n._getNetWork({
            url: e,
            validateBol: 2,
            success: function(t) {
                var e = t.data;
                1 == e.result && e.data.captcha && a.setData({
                    imgcode: e.data.captcha.img
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    _initInviteCode: function(t) {
        this.setData({
            invite: t.status,
            isrequired: t.required,
            country_code: t.country_code
        }), t.invitation_code && this.setData({
            "form.invite_code": t.invitation_code.invite_code
        });
    },
    _getDiyFormInfo: function(t) {
        this.setData({
            diyform: t,
            form_id: t.id,
            "datas.form_id": t.id
        });
        var a = this.data.diyform.fields, e = this.data.diydata, i = {};
        for (var s in a) {
            if ("diycheckbox" == this.data.types[a[s].data_type]) i = {
                name: s,
                data: a[s],
                value: [],
                type: this.data.types[a[s].data_type]
            }; else if ("diyselect" == this.data.types[a[s].data_type]) {
                for (var o = [], r = 0; r < a[s].tp_text.length; r++) o.push({
                    name: a[s].tp_text[r]
                });
                i = {
                    name: s,
                    data: a[s],
                    value: "",
                    type: this.data.types[a[s].data_type],
                    diysishow: !1,
                    sitem: o
                };
            } else i = "diycity" == this.data.types[a[s].data_type] ? {
                name: s,
                data: a[s],
                value: "",
                type: this.data.types[a[s].data_type],
                showAdd: !1
            } : "diydate" == this.data.types[a[s].data_type] ? {
                name: s,
                data: a[s],
                value: "",
                type: this.data.types[a[s].data_type],
                timeShow: !1,
                currentDate: new Date().getTime()
            } : "diyimage" == this.data.types[a[s].data_type] ? {
                name: s,
                data: a[s],
                imgUrls: a[s].value ? a[s].value : [],
                isPhoto: !1,
                type: this.data.types[a[s].data_type]
            } : {
                name: s,
                data: a[s],
                value: "",
                type: this.data.types[a[s].data_type]
            };
            e.push(i), this.setData({
                diydata: e
            });
        }
    },
    onRead_1: function(t) {
        try {
            var a = this.data.diydata, e = t.currentTarget.dataset.idex;
            if ("diyimage" == a[e].type && a[e].imgUrls.length >= a[e].data.tp_max) return void wx.showToast({
                title: "最多只能上传".concat(a[e].data.tp_max, "张"),
                icon: "none",
                duration: 1e3
            });
        } catch (t) {
            console.log(t);
        }
        var i = t.currentTarget.dataset.name;
        this.setData({
            setname: i
        });
        var s = this, o = n.getNetAddresss(this.data.uploadUrl);
        wx.chooseImage({
            count: 1,
            sizeType: [ "original", "compressed" ],
            sourceType: [ "album", "camera" ],
            success: function(t) {
                var a = t.tempFilePaths;
                wx.compressImage({
                    src: a[0],
                    quality: 60,
                    success: function(t) {
                        var a = t.tempFilePath;
                        wx.uploadFile({
                            url: o,
                            filePath: a,
                            name: "file",
                            formData: {
                                attach: s.data.setname
                            },
                            success: function(t) {
                                var a = JSON.parse(t.data);
                                if (1 == a.result) {
                                    for (var e = s.data.diydata, i = 0; i < e.length; i++) e[i].name == a.data.attach && e[i].imgUrls.push(a.data.img_url);
                                    s.setData({
                                        diydata: e
                                    });
                                } else wx.showToast({
                                    icon: "none",
                                    title: a.msg,
                                    duration: 1500
                                });
                            }
                        });
                    },
                    fail: function(t) {
                        console.log(t);
                    },
                    complete: function(t) {}
                });
            }
        });
    },
    removeImg: function(t) {
        var a = t.currentTarget.dataset.indexc, e = t.currentTarget.dataset.index, i = this.data.diydata;
        i[e].imgUrls.splice(a, 1), this.setData({
            diydata: i
        });
    },
    _getProtocolStatus: function(t) {
        this.setData({
            agreementStatus: "1" === t.protocol || 1 === t.protocol,
            protocol_content: t.content,
            protocol_title: t.title,
            agreement_name: t.agreement_name || "平台协议",
            PlatformAgreement: t.new_agreement
        });
    },
    editCustom: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.custom_value": a
        });
    },
    getAllData: function() {
        var t = this, a = n.getNetAddresss("member.register.bindApiData");
        try {
            var e = wx.getStorageSync("isset");
            e && t.setData({
                isset: e
            });
        } catch (t) {
            console.log(t);
        }
        this.data.isset && (wx.removeStorage({
            key: "isset",
            success: function(t) {
                console.log(t.data);
            }
        }), a += "&close=1"), n._postNetWork({
            url: a,
            validateBol: 2,
            data: {
                not_validate_page: "0"
            },
            success: function(a) {
                var e = a.data;
                if (1 == e.result) {
                    if (t.setData({
                        formOpen: "1" == e.data.form_open
                    }), e.data.get_register_diy_form && 1 == e.data.get_register_diy_form.status ? (t.setData({
                        diyStatus: 1,
                        form_id: e.data.get_register_diy_form.form_id
                    }), e.data.get_diy_form_by_id && t._getDiyFormInfo(e.data.get_diy_form_by_id)) : t.setData({
                        diyStatus: 0
                    }), e.data.get_member_protocol && (t._getProtocolStatus(e.data.get_member_protocol), 
                    e.data.get_member_protocol.form && (t._initCustomForm(e.data.get_member_protocol.form), 
                    e.data.get_member_protocol.form.base && t.setData({
                        form_address: "1" == e.data.get_member_protocol.form.base.address ? e.data.get_member_protocol.form.base.address : "",
                        form_birthday: "1" == e.data.get_member_protocol.form.base.birthday && e.data.get_member_protocol.form.base.birthday,
                        form_sex: "1" == e.data.get_member_protocol.form.base.sex && e.data.get_member_protocol.form.base.sex,
                        form_name: "1" == e.data.get_member_protocol.form.base.name,
                        is_custom: "1" == e.data.get_member_protocol.custom_field.is_custom,
                        custom_title: e.data.get_member_protocol.custom_field.custom_title
                    })), e.data.get_member_protocol.register && t.setData({
                        top_img: e.data.get_member_protocol.register.top_img,
                        title1: e.data.get_member_protocol.register.title1,
                        title2: e.data.get_member_protocol.register.title2,
                        is_password: e.data.get_member_protocol.register.is_password
                    }), e.data.get_member_protocol.member)) {
                        var i = e.data.get_member_protocol.member;
                        i.birthmonth < 10 ? i.birthmonth = "-0".concat(i.birthmonth) : i.birthmonth = "-".concat(i.birthmonth), 
                        i.birthday < 10 ? i.birthday = "-0".concat(i.birthday) : i.birthday = "-".concat(i.birthday), 
                        e.data.name_must && t.setData({
                            name_must: "1" == e.data.name_must
                        }), t.setData({
                            districtName: "".concat(i.province_name).concat(i.city_name).concat(i.area_name),
                            "form.address": i.address,
                            "form.birthday": "".concat(i.birthyear).concat(i.birthmonth).concat(i.birthday),
                            sexName: 0 == i.gender ? "女" : "男",
                            "form.custom_value": i.custom_value
                        });
                    }
                    e.data.get_captcha && t.getimgdata(e.data.get_captcha), e.data.getInviteCode && (t.setData({
                        default_invite: e.data.getInviteCode.default_invite
                    }), t._initInviteCode(e.data.getInviteCode));
                } else wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    countryinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.country": a.trim()
        });
    },
    captchainp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.captcha": a.trim()
        });
    },
    mobileinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.mobile": a.trim()
        });
    },
    sjnz: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.mobile": a.trim()
        });
    },
    codeinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.code": a.trim()
        });
    },
    inviteinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.invite_code": a.trim()
        });
    },
    passwordinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.password": a.trim()
        });
    },
    conpasswordinp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.confirm_password": a.trim()
        });
    },
    agreementCBinp: function(t) {
        var a = t.detail;
        this.setData({
            agreementCB: a
        });
    },
    goAgreement: function() {
        this.setData({
            show2: !0
        });
    },
    popClose: function() {
        this.setData({
            show2: !1
        });
    },
    openPlatformAgreement: function() {
        this.setData({
            showPlatformAgreement: !0
        });
    },
    closePlatformAgreement: function() {
        this.setData({
            showPlatformAgreement: !1
        });
    },
    sendCode: function(t) {
        if (this.data.start1) return !1;
        var a = 60, e = this;
        e.setData({
            start1: !0,
            codetext: "(" + a + ")秒后重新获取"
        });
        var i = setInterval(function() {
            e.setData({
                codetext: "(" + --a + ")秒后重新获取"
            });
        }, 1e3);
        setTimeout(function() {
            e.setData({
                codetext: "获取短信验证码",
                start1: !1
            }), clearInterval(i);
        }, 6e4), e.verificationCode(i);
    },
    verificationCode: function(t) {
        var a = this;
        if (n._isTextEmpty(this.data.form.country)) return wx.showToast({
            icon: "none",
            title: "请输入国际区号",
            duration: 1500
        }), a.setData({
            codetext: "获取短信验证码",
            start1: !1
        }), void clearInterval(t);
        if (n._isTextEmpty(this.data.form.mobile)) return wx.showToast({
            icon: "none",
            title: "请填写手机号",
            duration: 1500
        }), a.setData({
            codetext: "获取短信验证码",
            start1: !1
        }), void clearInterval(t);
        if ("86" == this.data.form.country && n._isMoblie(this.data.form.mobile)) wx.showToast({
            icon: "none",
            title: "请填写正确的手机号",
            duration: 1500
        }); else {
            if (n._isTextEmpty(this.data.form.captcha) && this.data.imgcode) return wx.showToast({
                icon: "none",
                title: "请填图形验证码",
                duration: 1500
            }), a.setData({
                codetext: "获取短信验证码",
                start1: !1
            }), void clearInterval(t);
            var e = n.getNetAddresss("member.register.sendCodeV2");
            e += "&mobile=" + this.data.form.mobile, e += "&state=" + this.data.form.country, 
            e += "&captcha=" + this.data.form.captcha, e += "&code=" + this.data.form.code, 
            n._getNetWork({
                url: e,
                validateBol: 2,
                success: function(e) {
                    var i = e.data;
                    1 == i.result ? wx.showToast({
                        icon: "none",
                        title: "已发送",
                        duration: 1500
                    }) : (wx.showToast({
                        icon: "none",
                        title: i.msg,
                        duration: 1500
                    }), a.setData({
                        "form.captcha": "",
                        start1: !1,
                        codetext: "获取短信验证码"
                    }), clearTimeout(t), a.getimgdata());
                },
                fail: function(t) {
                    console.log(t);
                }
            });
        }
    },
    tpnameinp: function(t) {
        var a = t.detail.value, e = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + e + "].value", a));
    },
    diytextareainp: function(t) {
        var a = t.detail.value, e = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + e + "].value", a));
    },
    checkboxinp: function(t) {
        var a = t.detail, e = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + e + "].value", a));
    },
    diyselectBtn: function(t) {
        var a = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + a + "].diysishow", !0));
    },
    sitemClose: function(t) {
        var a = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + a + "].diysishow", !1));
    },
    sitemSelectBtn: function(t) {
        var a, e = t.target.dataset.idex, s = t.detail.name;
        this.setData((i(a = {}, "diydata[" + e + "].value", s), i(a, "diydata[" + e + "].diysishow", !1), 
        a));
    },
    raidinp: function(t) {
        var a = t.detail, e = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + e + "].value", a));
    },
    showAddBtn: function(t) {
        var a = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + a + "].showAdd", !0));
    },
    _closeDateLw: function(t) {
        var a = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + a + "].showAdd", !1));
    },
    resultAdd: function(t) {
        var a, e = t.currentTarget.dataset.idex, s = this.data.selectAddressData, o = s[0].name + " " + s[1].name + " " + s[2].name;
        this.setData((i(a = {}, "diydata[" + e + "].value", o), i(a, "diydata[" + e + "].showAdd", !1), 
        a));
    },
    openPicker: function(t) {
        var a = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + a + "].timeShow", !0));
    },
    PickerClose: function(t) {
        var a = t.currentTarget.dataset.idex;
        this.setData(i({}, "diydata[" + a + "].timeShow", !1));
    },
    PickerChange: function(t) {
        var a = t.currentTarget.dataset.idex, e = t.detail;
        this.setData(i({}, "diydata[" + a + "].currentDate", e));
    },
    birthdayconfirm: function(t) {
        var a, e = t.currentTarget.dataset.idex, s = t.detail, o = this.timestampToTime(s);
        this.setData((i(a = {}, "diydata[" + e + "].value", o), i(a, "diydata[" + e + "].timeShow", !1), 
        a));
    },
    timestampToTime: function(t) {
        var a = new Date(t);
        return a.getFullYear() + "-" + ((a.getMonth() + 1 < 10 ? "0" + (a.getMonth() + 1) : a.getMonth() + 1) + "-") + (a.getDate() < 10 ? "0" + a.getDate() : a.getDate());
    },
    register: function() {
        var t = {}, a = {};
        t.customDatas = this.data.customDatas, a.province_name = this.data.form.province_name, 
        a.city_name = this.data.form.city_name, a.area_name = this.data.form.area_name, 
        a.province = this.data.form.province, a.city = this.data.form.city, a.area = this.data.form.area, 
        a.address = this.data.form.address;
        var i = {
            invite_code: this.data.form.invite_code,
            country: this.data.form.country,
            mobile: this.data.form.mobile,
            mobileErr: this.data.form.mobileErr,
            password: this.data.form.password,
            passwordErr: this.data.form.passwordErr,
            confirm_password: this.data.form.confirm_password,
            confirm_passwordErr: this.data.form.confirm_passwordErr,
            captcha: this.data.form.captcha,
            gender: this.data.form.gender,
            code: this.data.form.code,
            birthday: this.data.form.birthday,
            custom_value: this.data.form.custom_value,
            close: this.data.form.close
        };
        i.address = a, i.realname = this.data.form.realname, i.customDatas = t.customDatas;
        var s = this;
        if (this.data.formOpen && this.data.customDatas instanceof Array && 1 != this.data.editType && !this.data.customDatas.every(function(t) {
            return "" != t.value;
        })) return void wx.showToast({
            icon: "none",
            title: "请先填写自定义信息",
            duration: 1500
        });
        if (!this.data.repeatStatus) {
            if (this.setData({
                repeatStatus: !0
            }), !this.data.isset) {
                var o = e({}, i);
                this.setData({
                    is_form: o
                });
            }
            if (this.data.isset) {
                wx.removeStorage({
                    key: "isset",
                    success: function(t) {
                        console.log(t.data);
                    }
                });
                var r = e({}, i);
                this.setData({
                    is_form: r
                }), s.data.is_form.close = 1;
            }
            var d = n.getNetAddresss("member.member.bindMobile");
            n._postNetWork({
                url: d,
                showToastIn: !1,
                data: s.data.is_form,
                validateBol: 2,
                success: function(t) {
                    s.setData({
                        repeatStatus: !1
                    });
                    var a = t.data;
                    if (1 == a.result) {
                        if (n.resetBasicInfo(), s.data.changidInfo && s.data.changidInfo.change_uid && wx.setStorage({
                            key: "yz_uid",
                            data: s.data.changidInfo.change_uid
                        }), 0 == s.data.diyStatus) {
                            if (wx.showToast({
                                icon: "none",
                                title: "绑定成功",
                                duration: 1500
                            }), s.data.anchorApplyBol) return void wx.navigateBack({
                                delta: 1
                            });
                            if (1 == s.data.isset && !s.data.editType) return wx.removeStorage({
                                key: "isset",
                                success: function(t) {}
                            }), void wx.reLaunch({
                                url: "/" + n.globalData.beforeBindMobilePage,
                                fail: function(t) {
                                    wx.reLaunch({
                                        url: "/packageG/index/index"
                                    });
                                }
                            });
                            s.gotourl();
                        } else if (1 == s.data.diyStatus) {
                            s.selectComponent(".dsfrom").submit();
                        }
                    } else wx.showToast({
                        icon: "none",
                        title: a.msg,
                        duration: 1500
                    });
                },
                fail: function(t) {}
            });
        }
    },
    getPrepBind: function() {
        var t = this;
        if (this.data.name_must && "1" != this.data.editType && n._isTextEmpty(this.data.form.realname)) n.tips("请输入姓名"); else if (n._isTextEmpty(this.data.form.country)) wx.showToast({
            icon: "none",
            title: "请输入国际区号",
            duration: 1500
        }); else if (n._isTextEmpty(this.data.form.mobile)) wx.showToast({
            icon: "none",
            title: "请填写手机号",
            duration: 1500
        }); else if ("86" == this.data.form.country && n._isMoblie(this.data.form.mobile)) wx.showToast({
            icon: "none",
            title: "请填写正确的手机号",
            duration: 1500
        }); else if (n._isTextEmpty(this.data.form.code)) wx.showToast({
            icon: "none",
            title: "请填验证码",
            duration: 1500
        }); else {
            if ("1" == this.data.is_password) {
                if (n._isTextEmpty(this.data.form.password)) return void wx.showToast({
                    icon: "none",
                    title: "请填写密码",
                    duration: 1500
                });
                if (n._isTextEmpty(this.data.form.confirm_password)) return void wx.showToast({
                    icon: "none",
                    title: "请填写确认密码",
                    duration: 1500
                });
                if (this.data.form.password != this.data.form.confirm_password) return void wx.showToast({
                    icon: "none",
                    title: "两次密码不一致",
                    duration: 1500
                });
            }
            if (1 == this.data.isrequired && n._isTextEmpty(this.data.form.invite_code)) wx.showToast({
                icon: "none",
                title: "请填写邀请码",
                duration: 1500
            }); else {
                if (this.data.formOpen && this.data.isForm && 1 != this.data.editType) for (var a = 0; a < this.data.customDatas.length; a++) if (n._isTextEmpty(this.data.customDatas[a].value)) return void n.tips("请输入".concat(this.data.customDatas[a].name));
                if (this.data.imgcode && n._isTextEmpty(this.data.form.captcha)) wx.showToast({
                    icon: "none",
                    title: "图形验证码不能为空",
                    duration: 1500
                }); else if (1 != this.data.diyStatus || (this.validation(), this.data.isValidation)) if (!this.data.PlatformAgreement || this.data.agreementCB) if (!this.data.agreementStatus || this.data.agreementCB) {
                    if (!this.data.repeatStatus) {
                        if (this.setData({
                            repeatStatus: !0
                        }), !this.data.isset) {
                            var i = e({}, this.data.form);
                            this.setData({
                                form: i
                            });
                        }
                        Object.assign(this.data.form, this.data.orderLocationObj);
                        var s = n.getNetAddresss("member.member.prepBind");
                        n._postNetWork({
                            url: s,
                            showToastIn: !1,
                            data: this.data.form,
                            validateBol: 2,
                            success: function(a) {
                                t.setData({
                                    repeatStatus: !1
                                });
                                var e = a.data;
                                if (1 == e.result) if (e.data.is_show) {
                                    var i = wx.getStorageSync("yz_basic_info");
                                    t.setData({
                                        balance: i.balance,
                                        point: i.point,
                                        showChangeID: !0,
                                        changidInfo: {
                                            uid: e.data.uid,
                                            change_uid: e.data.change_uid
                                        }
                                    });
                                } else t.register(); else wx.showToast({
                                    icon: "none",
                                    title: e.msg,
                                    duration: 1500
                                });
                            },
                            fail: function(t) {}
                        });
                    }
                } else wx.showToast({
                    icon: "none",
                    title: "请先勾选同意" + this.data.protocol_title || "会员注册协议",
                    duration: 2e3
                }); else wx.showToast({
                    icon: "none",
                    title: "请先勾选同意" + this.data.agreement_name,
                    duration: 2e3
                });
            }
        }
    },
    closeChangeId: function() {
        this.setData({
            showChangeID: !1
        });
    },
    validation: function() {
        var t = this;
        this.setData({
            isValidation: !0
        }), this.data.diydata.forEach(function(a) {
            1 == a.data.tp_must && !a.value && a.type && (wx.showToast({
                icon: "none",
                title: a.data.tp_name + "必须填写哦",
                duration: 1500
            }), t.setData({
                isValidation: !0
            })), "diycheckbox" == a.type && 0 == a.value.length && (wx.showToast({
                icon: "none",
                title: a.data.tp_name + "必须选择哦",
                duration: 1500
            }), t.setData({
                isValidation: !1
            }));
        });
    },
    postDiy: function(t) {
        var a = this, e = this, i = {
            form_data: t.detail,
            form_id: this.data.form_id,
            form_type: "register"
        }, s = n.getNetAddresss("plugin.diyform.api.diy-form.save-diy-form-data");
        n._postNetWork({
            url: s,
            showToastIn: !1,
            data: i,
            success: function(t) {
                var i = t.data;
                1 == i.result ? (wx.showToast({
                    title: "绑定成功",
                    icon: "none",
                    duration: 1500,
                    success: function() {
                        setTimeout(function() {
                            e.gotourl();
                        }, 1500);
                    }
                }), a.data.is_code && a.address_codeMethod()) : wx.showToast({
                    icon: "none",
                    title: i.msg,
                    duration: 1500
                });
            },
            fail: function(t) {}
        });
    },
    address_codeMethod: function() {
        var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : wx.getStorageSync("yz_basic_info");
        if (n.data.address_code) try {
            var a = t;
            if (a.plugin_setting.address_code && a.plugin_setting.address_code.enable) {
                var e = n.getNetAddresss("plugin.address-code.frontend.index.set-address");
                n._postNetWork({
                    url: e,
                    data: {
                        address_id: n.data.address_code
                    },
                    success: function(t) {
                        1 == t.data.result && (n.data.address_code = "");
                    }
                });
            }
        } catch (t) {
            console.log(t);
        }
    },
    gotourl: function() {
        if (0 != this.data.fromApp && null != this.data.fromApp) 1 == this.data.fromApp || 3 == this.data.fromApp ? wx.reLaunch({
            url: "/" + n.globalData.beforeBindMobilePage,
            fail: function() {
                wx.reLaunch({
                    url: "/packageG/index/index"
                });
            }
        }) : 2 == this.data.fromApp ? wx.reLaunch({
            url: "/packageG/member_v2/member_v2"
        }) : 4 == this.data.fromApp ? wx.reLaunch({
            url: "/packageG/pages/member/extension/extension"
        }) : 5 == this.data.fromApp && wx.reLaunch({
            url: "/" + n.globalData.beforeBindMobilePage,
            fail: function() {
                wx.reLaunch({
                    url: "/packageG/index/index"
                });
            }
        }); else if (this.data.yzredirect) try {
            wx.reLaunch({
                url: "/" + this.data.yzredirect,
                fail: function() {
                    wx.reLaunch({
                        url: "/packageG/index/index"
                    });
                }
            });
        } catch (t) {
            wx.navigateBack({
                delta: 1,
                fail: function() {
                    wx.reLaunch({
                        url: "/packageG/index/index"
                    });
                }
            });
        } else wx.navigateBack({
            delta: 1,
            fail: function() {
                wx.reLaunch({
                    url: "/packageG/index/index"
                });
            }
        });
    },
    bindDateChange: function(t) {
        var a, e = t.target.dataset.idex, s = t.detail.value;
        this.setData((i(a = {}, "diydata[" + e + "].value", s), i(a, "diydata[" + e + "].timeShow", !1), 
        i(a, "date", s), a));
    },
    getCurrentOrderLocation: function() {
        var t = this;
        wx.getLocation({
            type: "gcj02",
            success: function(a) {
                console.log("userLocationFlag", a);
                var e = a.latitude, i = a.longitude;
                n.getReverseGeocoder(e, i).then(function(a) {
                    console.log("userLocationFlag", a);
                    var e = a.address_component, i = {
                        positioning_success: 1,
                        register_province: e.province,
                        register_city: n._isTextEmpty(e.city) ? e.province : e.city
                    };
                    t.data.orderLocationObj = i;
                }).catch(function(t) {
                    console.log(t);
                });
            }
        });
    },
    _setOrderLocation: function(t) {
        var a = this;
        n.getReverseGeocoder(t.lat, t.lng).then(function(t) {
            console.log("userLocationFlag", t);
            var e = t.address_component, i = {
                positioning_success: 1,
                register_province: e.province,
                register_city: n._isTextEmpty(e.city) ? e.province : e.city
            };
            a.data.orderLocationObj = i;
        }).catch(function(t) {
            console.log(t);
        });
    },
    checkAlbum: function(t) {
        var a = this;
        return o(s.default.mark(function e() {
            var i;
            return s.default.wrap(function(e) {
                for (;;) switch (e.prev = e.next) {
                  case 0:
                    return e.next = 2, a.getAuthSetting(t);

                  case 2:
                    return i = e.sent, e.abrupt("return", new Promise(function(a, e) {
                        i ? a(!0) : wx.showModal({
                            title: "请开启授权",
                            content: "是否跳转设置页开启授权",
                            success: function(e) {
                                e.confirm ? wx.openSetting({
                                    success: function(e) {
                                        e.authSetting[t] ? a(!0) : a(!1);
                                    }
                                }) : e.cancel && a(!1);
                            },
                            fail: function() {
                                a(!1);
                            }
                        });
                    }));

                  case 4:
                  case "end":
                    return e.stop();
                }
            }, e);
        }))();
    },
    getAuthSetting: function(t) {
        return new Promise(function(a, e) {
            wx.getSetting({
                success: function(e) {
                    e.authSetting[t] ? a(!0) : wx.authorize({
                        scope: t,
                        success: function() {
                            a(!0);
                        },
                        fail: function() {
                            a(!1);
                        }
                    });
                },
                fail: function() {
                    a(!1);
                }
            });
        });
    },
    tips: function(t) {
        return wx.showToast({
            title: t,
            icon: "none",
            duration: 2e3
        }), !1;
    },
    realnameInp: function(t) {
        var a = t.detail.value;
        this.setData({
            "form.realname": a
        });
    },
    SetPwdClick: function() {
        this.setData({
            visibleSet: !this.data.visibleSet
        });
    },
    surePwdClick: function() {
        this.setData({
            visibleSure: !this.data.visibleSure
        });
    }
});